package com.oceansoft.mobile.econsole.modules.api.service.impl;

import com.oceansoft.mobile.econsole.common.constant.Constant;
import com.oceansoft.mobile.econsole.modules.api.service.ICityTabService;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.jlwt.entity.SysOrg;
import com.oceansoft.mobile.econsole.modules.jlwt.persistence.ISysOrgMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by wzy on 2016/1/29.
 */
@Service
public class CityTabServiceImpl implements ICityTabService {

    @Resource
    private ISysOrgMapper sysOrgMapper;

    @Override
    public Result getRegion() {

        List<SysOrg> regions = sysOrgMapper.getRegion(Constant.ORG_TOP, Constant.ORG_STYPE_DS);

        for(SysOrg e : regions){
            e.setOrgName(e.getOrgName().replace("公安局",""));
        }
        return  new Result( Result.SUCC,  regions);
    }


    @Override
    public Result getSubstation(String parentGuid) {

        List<SysOrg> subStations = sysOrgMapper.getRegion(parentGuid,Constant.ORG_STYPE_FJ);
        return  new Result(Result.SUCC,subStations);

    }

    @Override
    public SysOrg findSysOrgById(String guid){
        return sysOrgMapper.findById(guid,Constant.ORG_STYPE_DS);
    }
}
